// pages/peccancy/bond.js
const app = getApp()
Page({

    data: {
        more: false,
    },

    onLoad: function(options) {
		options.service_money = wx.getStorageSync('TICKET_SERVICE_MONEY')
        this.setData(options)
        this.loadData()
    },
    /**
     * offerInfo.status 1待中标  2 已中标 3 已撤销
     */
    loadData() {
        wx.showLoading({
            title: '加载中...',
        })
        Promise.all([
            app.http.post('rest/ticket/queryById.do', {
                data: this.data.id
            }),
            app.http.post('rest/quote/queryById.do', {
                data: this.data.cid
            })
        ]).then(res => {
            res[0].obj.pay_money = parseFloat(res[1].obj.price) + parseFloat(this.data.service_money)
            this.setData(Object.assign({
                offerInfo: res[1].obj,
            }, res[0].obj))
            wx.hideLoading()
        })
    },
    more() {
        this.setData({
            more: !this.data.more
        })
    },
    submit() {
        wx.showModal({
            title: '',
            content: '共需支付' + this.data.pay_money + '元(服务费' + this.data.service_money + '元)',
			showCancel:false,
			confirmColor:'#007AFF',
			success:res=>{
				if(res.confirm){
					wx.showLoading({
						title: '加载中...',
					})
					getApp().http.post('rest/ticket/confirmQuote.do', {
						data: this.data.cid,
						showMsg: false
					}).then(res => {
						wx.hideLoading()
						wx.navigateTo({
							url: '../personal/order-success?id=' + this.data.id,
						})
					})
				}
			}
        })
    }
    // returnOfferList() {
    // 	if (app.getPrevPage() && app.getPrevPage().route == 'pages/agency/demand/demand-detail') {
    // 		wx.navigateBack({})
    // 		return
    // 	}
    // 	wx.redirectTo({
    // 		url: '/pages/agency/demand/demand-detail?id=' + this.data.id,
    // 	})
    // }

})